package com.zj.fx.service.info;

import java.util.*;

import com.zj.fx.mapper.info.InfoProjectMapper;
import com.zj.fx.model.custom.InfoProjectVo;
import com.zj.fx.model.info.InfoProject;
import com.zj.fx.model.info.InfoProjectExample;
import com.zj.fx.model.month.MonthSupplytaskDtl;
import com.zj.fx.shiro.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.zj.fx.common.base.BaseService;
import com.zj.fx.common.support.ConvertUtil;
import com.zj.fx.model.custom.Tablepar;
import com.zj.fx.util.SnowflakeIdWorker;

/**
 * 管理提升项目 InfoProjectService
 * @Title: InfoProjectService.java 
 * @Package com.zj.fx.service 
 * @author SQL_自动生成
 * @email ${email}
 * @date 2023-06-08 13:33:35  
 **/
@Service
public class InfoProjectService implements BaseService<InfoProject, InfoProjectExample> {
    @Autowired
    private InfoProjectMapper infoProjectMapper;

                                                                                        
    /**
     * 分页查询
     * @param
     * @param
     * @return
     */
    public PageInfo<InfoProject> list(Tablepar tablepar,InfoProject infoProject) {
            InfoProjectExample testExample = new InfoProjectExample();
        //搜索
        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
        } else {//大搜索
            testExample.createCriteria().andLikeQuery(infoProject);
        }
        //表格排序
        //if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
        //}else{
        //	testExample.setOrderByClause("id ASC");
        //}
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<InfoProject> list = infoProjectMapper.selectByExample(testExample);
        PageInfo<InfoProject> pageInfo = new PageInfo<InfoProject>(list);
        return pageInfo;
    }
    
        @Override
        public int deleteByPrimaryKey(String ids) {
            
                List<String> lista = ConvertUtil.toListStrArray(ids);
                    InfoProjectExample example = new InfoProjectExample();
                example.createCriteria().andIdIn(lista);
                return infoProjectMapper.deleteByExample(example);

            
        }


        @Override
        public InfoProject selectByPrimaryKey(String id) {
            
                return infoProjectMapper.selectByPrimaryKey(id);
            
        }


        @Override
        public int updateByPrimaryKeySelective(InfoProject record) {
            return infoProjectMapper.updateByPrimaryKeySelective(record);
        }

    
    /**
     * 添加
     */
    @Override
    public int insertSelective(InfoProject record) {
        
            //添加雪花主键id
            record.setId(SnowflakeIdWorker.getUUID());

        
        return infoProjectMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(InfoProject record, InfoProjectExample example) {

        return infoProjectMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(InfoProject record, InfoProjectExample example) {

        return infoProjectMapper.updateByExample(record, example);
    }

    @Override
    public List<InfoProject> selectByExample(InfoProjectExample example) {

        return infoProjectMapper.selectByExample(example);
    }


    @Override
    public long countByExample(InfoProjectExample example) {

        return infoProjectMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(InfoProjectExample example) {

        return infoProjectMapper.deleteByExample(example);
    }


    public List<InfoProject> selectTabTitle() {
        List<InfoProject> resultList = new ArrayList<>();
        InfoProject infoProject = new InfoProject();
        infoProject.setId("0");
        infoProject.setNum("0");
        infoProject.setContent("必备条件");
        infoProject.setType("1");
        resultList.add(infoProject);
        //1、查询一级标签
        InfoProjectExample infoProjectExample = new InfoProjectExample();
        InfoProjectExample.Criteria criteria = infoProjectExample.createCriteria();
        criteria.andTypeEqualTo("1");
        infoProjectExample.setOrderByClause("NUM ASC");
//        infoProjectExample.setOrderByClause("NUM DESC");
        List<InfoProject> infoProjects = infoProjectMapper.selectByExample(infoProjectExample);
        resultList.addAll(infoProjects);
        return resultList;
    }
    /*
       填报模块三级项目信息查询
     */
    public List<InfoProjectVo> findupGrade3(InfoProjectVo infoProjectVo) {
        List<InfoProjectVo> list = infoProjectMapper.findupGrade3(infoProjectVo);
        return list;
    }

    public List<InfoProjectVo> list2(InfoProjectVo infoProjectVo) {
        List<InfoProjectVo> list = infoProjectMapper.findupGrade3(infoProjectVo);
        return list;
    }


    public List<InfoProjectVo> list3(InfoProjectVo infoProjectVo) {
        List<InfoProjectVo> list = infoProjectMapper.findupGrade4(infoProjectVo);
        return list;
    }

    public List<InfoProject> selectgrade4() {
        InfoProjectExample infoProjectExample = new InfoProjectExample();
        InfoProjectExample.Criteria criteria = infoProjectExample.createCriteria();
        criteria.andTypeEqualTo("4");
        infoProjectExample.setOrderByClause("NUM ASC");
        List<InfoProject> infoProjects = infoProjectMapper.selectByExample(infoProjectExample);
        return  infoProjects;
    }

    public List<InfoProject> getAuditTabbyDepandTaskID(String id) {
        MonthSupplytaskDtl monthSupplytaskDtl = new MonthSupplytaskDtl();
        monthSupplytaskDtl.setFkTaskId(id);
        monthSupplytaskDtl.setDeptId(ShiroUtils.getDepId());
        return infoProjectMapper.getAuditTabbyDepandTaskID(monthSupplytaskDtl);
    }

    public List<InfoProjectVo> findupGrade3Dep(MonthSupplytaskDtl monthSupplytaskDtl) {
        List<InfoProjectVo> list = infoProjectMapper.findupGrade3Dep(monthSupplytaskDtl);
        return list;
    }
}
